<template>
	<view class="mian">
		<view class="status_bar"></view>
		<Header title="红包记录"></Header>
		<!-- 下面的线 -->
		<!-- <view class="xian"></view> -->
		<!-- 下面的记录 -->
		<view class="body_box">
			<!-- /上面的top -->
			<scroll-view lower-threshold="50" @scrolltolower="scrolltolower" style="height: 100%" scroll-y="true">
				<view class="tabBar">
					<view @click="tab(1)" :class="[act==1?'active' :'']" class="le">
						全部
					</view>
					<view @click="tab(3)" :class="[act==3?'active' :'']" class="le">
						收入
					</view>
					<view @click="tab(2)" :class="[act==2?'active' :'']" class="le">
						支出
					</view>
				</view>
				<view class="liebiao">

					<view class="lie_son" v-for="(item,index) in listdata" :key="index">
						<view class="rig">
							<view class="top_tit">
								{{item.remark}}
							</view>
							<view class="top_time">
								{{item.created_at}}
							</view>
						</view>
						<view class="rig_pic">
							{{item.operation_type == 1?'+':'-'}}{{item.money}}
						</view>
					</view>

				</view>
				<view v-if="listdata.length==0" class="zanwu">
					<image src="http://img.cpgm.cc/panda/static/duoBao/baiwu.png" class="zaneu_img" mode="widthFix">
					</image>
					<view class="">
						没有数据哦~
					</view>
				</view>
				<u-loadmore v-else :status="status" :icon-type="iconType" :load-text="loadText" />
			</scroll-view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				act: 1,
				background: {
					backgroundColor: '#0E0E0E',
				},
				list: '',
				listdata: [],
				page: 1,
				max_page: 1,
				status: 'loadmore',
				iconType: 'flower',
				loadText: {
					loadmore: '轻轻上拉',
					loading: '努力加载中',
					nomore: '没有更多了'
				},
			}
		},
		onReachBottom() {

		},
		onLoad() {
			this.getmoneyDetailList()
		},
		methods: {
			scrolltolower() {
				if (this.page >= this.max_page) {
					this.status = 'nomore'
					return;
				}
				this.status = 'loading';
				this.page = ++this.page;
				this.getmoneyDetailList()
				setTimeout(() => {
					if (this.page > this.max_page || this.page == this.max_page) this.status = 'nomore';
					else this.status = 'loading';
				}, 500)
			},
			async getmoneyDetailList() {
				let res = await this.$http.index.redMoneyList({
					page: this.page,
					type: this.act
				})
				this.list = res.data
				this.max_page = res.page
				this.listdata = [...this.listdata, ...this.list]
				if (this.page > this.max_page || this.page == this.max_page) this.status = 'nomore';
			},
			tab(num) {
				this.act = num
				if (num == 1) {
					this.page = 1
					this.listdata = []
					this.getmoneyDetailList()
					// 说明是第一列
				} else if (num == 2) {
					this.page = 1
					this.listdata = []
					this.getmoneyDetailList()
					// 说明是第二列
				} else if (num == 3) {
					this.page = 1
					this.listdata = []
					this.getmoneyDetailList()
					// 说明第三列
				}
			}
		}
	}
</script>

<style lang="scss" scoped>
	* {
		box-sizing: border-box;
	}

	.body_box {
		height: 90%;
		width: 95%;
		margin: 0 auto;
		border-radius: 15px;
		padding: 10px;
		background-color: #fff;
		overflow-y: auto;


		.tabBar {
			display: flex;
			align-items: center;
			justify-content: center;

			.le {
				height: 38px;
				line-height: 38px;
				text-align: center;
				width: 25%;
				background-color: #f6f6f6;
				margin-right: 10px;
				border-radius: 8px;
				font-size: 14px;
				font-family: PingFangSC-Semibold, PingFang SC;
				font-weight: 600;
				color: #A1A1A1;
			}

			.active {
				background: linear-gradient(180deg, #FF587D 0%, #F62F5D 100%), linear-gradient(270deg, #FF456B 0%, #FE5C4F 100%);
				color: #fff;
			}
		}
	}

	.mian {
		height: 100vh;
		width: 390px;
		height: 844px;
		background: linear-gradient(180deg, #f6e4e7 0%, #f6e6e5 100%);
		// opacity: 0.1;
	}

	.xian {
		background-color: #d7e5f0;
		height: 1px;
	}

	.zanwu {
		font-size: 14px;
		color: #A1A1A1;
		font-weight: 500;
		margin-top: 50%;
		text-align: center;

		.zaneu_img {
			width: 70%;

		}
	}

	.liebiao {
		// height: calc(100vh - 61px);
		overflow-y: auto;

		.lie_son {
			width: 80%;
			height: 70px;
			margin: 0 auto;
			border-bottom: 1px solid #d7e5f0;
			display: flex;
			align-items: center;
			justify-content: space-between;

			.top_tit {
				font-size: 14px;
				font-family: SourceHanSansCN-Medium, SourceHanSansCN;
				font-weight: 500;
				color: #131314;
			}

			.top_time {
				margin-top: 5px;
				font-size: 11px;
				font-family: SourceHanSansCN-Medium, SourceHanSansCN;
				font-weight: 500;
				color: #A1A1A1
			}

			.rig_pic {
				font-size: 16px;
				font-family: SourceHanSansCN-Bold, SourceHanSansCN;
				font-weight: bold;
				color: #131314;
			}
		}
	}
</style>